package com.frogs.ucenter.v1.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.frogs.framework.base.web.BaseController3;
import com.frogs.system.web.api.response.FailResponse;
import com.frogs.system.web.api.response.Response;
import com.frogs.system.web.exception.AppBaseException;
import com.frogs.ucenter.v1.request.OpenPlatformBindAndLoginRequest;
import com.frogs.ucenter.v1.request.OpenPlatformLoginRequest;
import com.frogs.ucenter.v1.request.OpenPlatformSendActivateEmailRequest;
import com.frogs.ucenter.v1.request.SmsSendDynamicPasswordRequest;
import com.frogs.ucenter.v1.request.UserAccountAuthorizationUpdateRequest;
import com.frogs.ucenter.v1.request.UserAccountDetailRequest;
import com.frogs.ucenter.v1.request.UserAccountInfoAddRequest;
import com.frogs.ucenter.v1.request.UserAccountInfoAutoRegisterRequest;
import com.frogs.ucenter.v1.request.UserAccountInfoListRequest;
import com.frogs.ucenter.v1.request.UserAccountInfoUpdateRequest;
import com.frogs.ucenter.v1.request.UserAccountNoviceUpdateRequest;
import com.frogs.ucenter.v1.request.UserBindEmailRequest;
import com.frogs.ucenter.v1.request.UserBindPhoneRequest;
import com.frogs.ucenter.v1.request.UserLoginByDynamicPasswordRequest;
import com.frogs.ucenter.v1.request.UserLoginNoPasswordRequest;
import com.frogs.ucenter.v1.request.UserLoginRequest;
import com.frogs.ucenter.v1.request.UserLogoutRequest;
import com.frogs.ucenter.v1.request.UserLostpasswordByAccountRequest;
import com.frogs.ucenter.v1.request.UserLostpasswordByEmailRequest;
import com.frogs.ucenter.v1.request.UserPasswordUpdateRequest;
import com.frogs.ucenter.v1.request.UserResetPasswordByPhoneRequest;
import com.frogs.ucenter.v1.request.UserResetPasswordRequest;
import com.frogs.ucenter.v1.request.UserUnbindEmailRequest;
import com.frogs.ucenter.v1.request.UserUnbindPhoneRequest;
import com.frogs.ucenter.v1.request.UserVerifyBindPhoneRequest;
import com.frogs.ucenter.v1.request.UserVerifyEmailRequest;
import com.frogs.ucenter.v1.request.UserVerifyNameRequest;
import com.frogs.ucenter.v1.request.UserVerifyPhoneRequest;
import com.frogs.ucenter.v1.request.UserVerifyRequest;
import com.frogs.ucenter.v1.request.WechatUserInfoRequest;
import com.frogs.ucenter.v1.request.WechatUserInfoUpdateRequest;
import com.frogs.ucenter.v1.request.WechatUserPhoneBindRequest;
import com.frogs.ucenter.v1.request.WechatUserPhoneUnBindRequest;
import com.frogs.ucenter.v1.request.WechatUserVerifyPhoneRequest;
import com.frogs.ucenter.v1.service.UserAccountInfoService;
import com.frogs.ucenter.v1.util.ApiConstants;

/**
 *
 * @author lijian
 * @version 2014年3月25日 - 下午8:13:05
 */
@Controller(ApiConstants.VERSION+"userAccountInfoController")
@RequestMapping("/"+ApiConstants.VERSION)
public class UserAccountInfoController extends BaseController3 {

	private static final String ROOT = "/user";
	private static final String USER_ACCOUNT_REGISTER = ROOT + "/account/register";
	private static final String USER_ACCOUNT_UPDATE = ROOT + "/account/update";
	private static final String USER_ACCOUNT_AUTHORIZATION_UPDATE = ROOT + "/account/authorization/update";
	private static final String USER_ACCOUNT_NOVICE_UPDATE = ROOT + "/account/novice/update";
	
	private static final String USER_ACCOUNT_DETAIL = ROOT + "/account/detail";
	private static final String USER_PASSWORD_UPDATE = ROOT + "/password/update";
	private static final String USER_NAME_VERIFY = ROOT + "/name/verify";
	private static final String USER_EMAIL_VERIFY = ROOT + "/email/verify";
	private static final String USER_PHONE_VERIFY = ROOT + "/phone/verify";
	private static final String USER_LOGIN = ROOT + "/login";
	private static final String USER_LOGOUT = ROOT + "/logout";
	private static final String USER_IS_LOGIN = ROOT + "/verify";
	private static final String USER_PASSWORD_LOST_BY_EMAIL = ROOT + "/lost/byEmail";
	private static final String USER_PASSWORD_RESET_BY_PHONE = ROOT + "/reset/byPhone";
	private static final String USER_PASSWORD_LOST_BY_ACCOUNT = ROOT + "/lost/account";
	private static final String USER_PASSWORD_RESET = ROOT + "/password/reset";
	private static final String USER_EMAIL_BIND = ROOT + "/email/bind";
	private static final String USER_EMAIL_UNBIND = ROOT + "/email/unbind";
	private static final String USER_PHONE_BIND = ROOT + "/phone/bind";
	private static final String USER_PHONE_UNBIND = ROOT + "/phone/unbind";
	private static final String USER_ACCOUNT_LIST = ROOT + "/list";
	private static final String USER_IS_BIND_PHONE = ROOT + "/bindPhone/verify";
	private static final String USER_DYNAMIC_PASSWORD_LOGIN = ROOT + "/loginByDpw";
	private static final String USER_DYNAMIC_PASSWORD_SEND = ROOT + "/dynamicPw/send";
	private static final String USER_ACCOUNT_AUTO_REGISTER = ROOT + "/autoRegister";
	private static final String USER_LOGIN_NO_PASS_WORD = ROOT + "/loginNoPW";
	private static final String WECHAT_USER_DETAIL = ROOT +"/wechat/detail";
	
	private static final String WECHAT_USER_UPDATE = ROOT + "/wechat/update";
	private static final String WECHAT_USER_PHONE_BIND = ROOT + "/wechat/phone/bind";
	private static final String WECHAT_USER_PHONE_UNBIND = ROOT + "/wechat/phone/unbind";
	private static final String WECHAT_USER_PHONE_VERIFY = ROOT + "/wechat/phone/verify";

	private static final String USER_OPEN_PLATFORM_LOGIN = ROOT + "/openPlatform/login";
	private static final String USER_OPEN_PLATFORM_BIND_AND_LOGIN = ROOT + "/openPlatform/bindAndLogin";
	private static final String USER_OPEN_PLATFORM_ACTIVITE_EMAIL_SEND = ROOT + "/openPlatform/activiteEmail/send";
	private static final String OBTAIN_USER_AUTHORIZATION =  ROOT + "/obtain/authorization"; 
	
	@Resource(name=ApiConstants.VERSION + "userAccountInfoService")
	private UserAccountInfoService userAccountInfoService;

	/**
	 * 注册账号接口
	 * 
	 * TODO 暂缺发邮件功能
	 * 
	 * @param request
	 * @return
	 * 
	 * url :http://api.uc.frogshealth.com/v1/user/account/register.jsonp?uuid=1&token=1&uid=1&callback=test
	 */
	
	@RequestMapping(USER_ACCOUNT_REGISTER)
	public Response userAccountAdd(HttpServletRequest request) {
		Response response;
		try {
			UserAccountInfoAddRequest userAccountInfoAddRequest = new UserAccountInfoAddRequest();
			userAccountInfoAddRequest.parse(request);
			response = userAccountInfoService.insert(userAccountInfoAddRequest);
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
	
	/**
	 * 用户名验证接口
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(USER_NAME_VERIFY)
	public Response userNameVerify(HttpServletRequest request) {
		Response response;
		try {
			UserVerifyNameRequest userVerifyRequest = new UserVerifyNameRequest();
			userVerifyRequest.parse(request);
			response = userAccountInfoService.verifyName(userVerifyRequest);
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
	
	/**
	 * 邮箱验证接口
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(USER_EMAIL_VERIFY)
	public Response userEmailVerify(HttpServletRequest request) {
		Response response;
		try {
			UserVerifyEmailRequest userVerifyEmailRequest = new UserVerifyEmailRequest();
			userVerifyEmailRequest.parse(request);
			response = userAccountInfoService.verifyEmail(userVerifyEmailRequest);
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
	
	/**
	 * 手机号码验证接口
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(USER_PHONE_VERIFY)
	public Response userPhoneVerify(HttpServletRequest request) {
		Response response;
		try {
			UserVerifyPhoneRequest userVerifyPhoneRequest = new UserVerifyPhoneRequest();
			userVerifyPhoneRequest.parse(request);
			response = userAccountInfoService.verifyPhone(userVerifyPhoneRequest);
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
	
	/**
	 * 登录接口
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(USER_LOGIN)
	public Response userLogin(HttpServletRequest request) {
		Response response;
		try {
			UserLoginRequest userLoginRequest = new UserLoginRequest();
			userLoginRequest.parse(request);
			response = userAccountInfoService.login(userLoginRequest);
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
	
	/**
	 * 用户退出接口
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(USER_LOGOUT)
	public Response userLogout(HttpServletRequest request) {
		Response response;
		try {
			UserLogoutRequest userLogoutRequest = new UserLogoutRequest();
			userLogoutRequest.parse(request);
			response = userAccountInfoService.logout(userLogoutRequest);
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
	
	/**
	 * 验证用户是否登录接口
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(USER_IS_LOGIN)
	public Response isLogin(HttpServletRequest request) {
		Response response;
		try {
			UserVerifyRequest userVerifyRequest = new UserVerifyRequest();
			userVerifyRequest.parse(request);
			response = userAccountInfoService.isLogin(userVerifyRequest);
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
	
	/**
	 * 获取用户详细信息接口
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(USER_ACCOUNT_DETAIL)
	public Response userAccountDetail(HttpServletRequest request) {
		Response response;
		try {
			UserAccountDetailRequest accountDetailRequest = new UserAccountDetailRequest();
			accountDetailRequest.parse(request);
			response = userAccountInfoService.getUser(accountDetailRequest);
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}

	@RequestMapping(value=USER_ACCOUNT_AUTHORIZATION_UPDATE,method=RequestMethod.POST)
	public Response userAccountAuthorizationUpdate(HttpServletRequest request) {
		Response response;
		try {
			UserAccountAuthorizationUpdateRequest userAccountAuthorizationUpdateRequest = new UserAccountAuthorizationUpdateRequest();
			userAccountAuthorizationUpdateRequest.parse(request);
			response = userAccountInfoService.updateAuthorization(userAccountAuthorizationUpdateRequest);
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
	
	@RequestMapping(value=USER_ACCOUNT_NOVICE_UPDATE,method=RequestMethod.POST)
	public Response userAccountNoviceUpdate(HttpServletRequest request) {
		Response response;
		try {
			UserAccountNoviceUpdateRequest userAccountInfoUpdateRequest = new UserAccountNoviceUpdateRequest();
			userAccountInfoUpdateRequest.parse(request);
			response = userAccountInfoService.updateNovice(userAccountInfoUpdateRequest);
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
	/**
	 * 账号更新接口
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(USER_ACCOUNT_UPDATE)
	public Response userAccountUpdate(HttpServletRequest request) {
		Response response;
		try {
			UserAccountInfoUpdateRequest userAccountInfoUpdateRequest = new UserAccountInfoUpdateRequest();
			userAccountInfoUpdateRequest.parse(request);
			response = userAccountInfoService.update(userAccountInfoUpdateRequest);
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
	
	/**
	 * 忘记密码账号验证接口
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(USER_PASSWORD_LOST_BY_ACCOUNT)
	public Response userPasswordLostByAccount(HttpServletRequest request) {
		Response response;
		try {
			UserLostpasswordByAccountRequest userLostpasswordByAccountRequest = new UserLostpasswordByAccountRequest();
			userLostpasswordByAccountRequest.parse(request);
			response = userAccountInfoService.lostpasswordByAccount(userLostpasswordByAccountRequest);
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
	
	/**
	 * 发送找回密码邮件接口
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(USER_PASSWORD_LOST_BY_EMAIL)
	public Response userPasswordLostByEmail(HttpServletRequest request) {
		Response response;
		try {
			UserLostpasswordByEmailRequest userLostpasswordByEmailRequest = new UserLostpasswordByEmailRequest();
			userLostpasswordByEmailRequest.parse(request);
			response = userAccountInfoService.sendEmailByLostpassword(userLostpasswordByEmailRequest);
			
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
	
	/**
	 * 重置密码接口
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(USER_PASSWORD_RESET)
	public Response userPasswdReset(HttpServletRequest request) {
		Response response;
		try {
			UserResetPasswordRequest userResetPasswordRequest = new UserResetPasswordRequest();
			userResetPasswordRequest.parse(request);
			response = userAccountInfoService.resetPasswd(userResetPasswordRequest);
			
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
	
	/**
	 * 更新密码接口
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(USER_PASSWORD_UPDATE)
	public Response userPasswordUpdate(HttpServletRequest request) {
		Response response;
		try {
			UserPasswordUpdateRequest passwordUpdateRequest = new UserPasswordUpdateRequest();
			passwordUpdateRequest.parse(request);
			response = userAccountInfoService.updatePasswd(passwordUpdateRequest);
			
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
	
	/**
	 * 绑定邮箱接口
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(USER_EMAIL_BIND)
	public Response userEmailBind(HttpServletRequest request) {
		Response response;
		try {
			UserBindEmailRequest userBindEmailRequest = new UserBindEmailRequest();
			userBindEmailRequest.parse(request);
			response = userAccountInfoService.bindEmail(userBindEmailRequest);
			
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
	
	/**
	 * 解绑邮箱接口
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(USER_EMAIL_UNBIND)
	public Response userEmailUnbind(HttpServletRequest request) {
		Response response;
		try {
			UserUnbindEmailRequest userUnbindEmailRequest = new UserUnbindEmailRequest();
			userUnbindEmailRequest.parse(request);
			response = userAccountInfoService.unbindEmail(userUnbindEmailRequest);
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
	
	/**
	 * 绑定手机号码接口
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(USER_PHONE_BIND)
	public Response userPhoneBind(HttpServletRequest request) {
		Response response;
		try {
			UserBindPhoneRequest userBindPhoneRequest = new UserBindPhoneRequest();
			userBindPhoneRequest.parse(request);
			response = userAccountInfoService.bindPhone(userBindPhoneRequest);
			
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
	
	/**
	 * 解绑手机号码接口
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(USER_PHONE_UNBIND)
	public Response userPhoneUnbind(HttpServletRequest request) {
		Response response;
		try {
			UserUnbindPhoneRequest userUnbindPhoneRequest = new UserUnbindPhoneRequest();
			userUnbindPhoneRequest.parse(request);
			response = userAccountInfoService.unbindPhone(userUnbindPhoneRequest);
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
	
	/**
	 * 根据手机号码重置密码接口
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(USER_PASSWORD_RESET_BY_PHONE)
	public Response userPasswordResetByPhone(HttpServletRequest request) {
		Response response;
		try {
			UserResetPasswordByPhoneRequest userResetPasswordByPhoneRequest = new UserResetPasswordByPhoneRequest();
			userResetPasswordByPhoneRequest.parse(request);
			response = userAccountInfoService.resetPasswdByPhone(userResetPasswordByPhoneRequest);
			
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
	
	/**
	 * 自动注册接口
	 * 注：目前只提供给微信使用,xxxx
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(USER_ACCOUNT_AUTO_REGISTER)
	public Response userAccountAutoRegister(HttpServletRequest request) {
		Response response;
		try {
			UserAccountInfoAutoRegisterRequest accountInfoAutoRegisterRequest = new UserAccountInfoAutoRegisterRequest();
			accountInfoAutoRegisterRequest.parse(request);
			response = userAccountInfoService.autoRegister(accountInfoAutoRegisterRequest);
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
	
	/**
	 * 免密码登录接口
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(USER_LOGIN_NO_PASS_WORD)
	public Response userLoginNoPw(HttpServletRequest request) {
		Response response;
		try {
			UserLoginNoPasswordRequest userLoginNoPasswordRequest = new UserLoginNoPasswordRequest();
			userLoginNoPasswordRequest.parse(request);
			response = userAccountInfoService.loginNoPassword(userLoginNoPasswordRequest);
			
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
	
	/**
	 * 获取微信用户信息接口
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping({WECHAT_USER_DETAIL})
	public Response wechatUserInfoDetail(HttpServletRequest request) {
		Response response;
		try {
			WechatUserInfoRequest wechatUserInfoRequest = new WechatUserInfoRequest();
			wechatUserInfoRequest.parse(request);
			response = userAccountInfoService.getWechatUserInfo(wechatUserInfoRequest);
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
	
	/**
	 * 更新微信用户信息接口
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(WECHAT_USER_UPDATE)
	public Response wechatUserUpdate(HttpServletRequest request) {
		Response response;
		try {
			WechatUserInfoUpdateRequest userInfoUpdateRequest = new WechatUserInfoUpdateRequest();
			userInfoUpdateRequest.parse(request);
			response = userAccountInfoService.updateWechatUserInfo(userInfoUpdateRequest);
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
	
	/**
	 * 绑定微信用户手机号码
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(WECHAT_USER_PHONE_BIND)
	public Response wechatUserPhoneBind(HttpServletRequest request) {
		Response response;
		try {
			WechatUserPhoneBindRequest wechatUserPhoneBindRequest = new WechatUserPhoneBindRequest();
			wechatUserPhoneBindRequest.parse(request);
			response = userAccountInfoService.bindWechatUserPhone(wechatUserPhoneBindRequest);
			
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
	
	/**
	 * 取消绑定微信用户手机号码
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(WECHAT_USER_PHONE_UNBIND)
	public Response wechatUserPhoneUnbind(HttpServletRequest request) {
		Response response;
		try {
			WechatUserPhoneUnBindRequest wechatUserPhoneUnBindRequest = new WechatUserPhoneUnBindRequest();
			wechatUserPhoneUnBindRequest.parse(request);
			response = userAccountInfoService.unbindWechatUserPhone(wechatUserPhoneUnBindRequest);
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
	
	/**
	 * 微信用户手机号码验证接口
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(WECHAT_USER_PHONE_VERIFY)
	public Response wechatUserPhoneVerify(HttpServletRequest request) {
		Response response;
		try {
			WechatUserVerifyPhoneRequest userVerifyPhoneRequest = new WechatUserVerifyPhoneRequest();
			userVerifyPhoneRequest.parse(request);
			response = userAccountInfoService.verifyWechatPhone(userVerifyPhoneRequest);
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
	
	/**
	 * 第三方平台登录接口
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(USER_OPEN_PLATFORM_LOGIN)
	public Response userOpenPlatformLogin(HttpServletRequest request) {
		Response response;
		try {
			OpenPlatformLoginRequest openPlatformLoginRequest = new OpenPlatformLoginRequest();
			openPlatformLoginRequest.parse(request);
			response = userAccountInfoService.openPlatformLogin(openPlatformLoginRequest);
			
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
	
	/**
	 * 第三方平台绑定接口
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(USER_OPEN_PLATFORM_BIND_AND_LOGIN)
	public Response bindOpenPlatformLogin(HttpServletRequest request) {
		Response response;
		try {
			OpenPlatformBindAndLoginRequest openPlatformBindAndLoginRequest = new OpenPlatformBindAndLoginRequest();
			openPlatformBindAndLoginRequest.parse(request);
			response = userAccountInfoService.bindOpenPlatformLogin(openPlatformBindAndLoginRequest);
			
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
	
	/**
	 * 判断该账号是否有绑定手机号码接口 
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(USER_IS_BIND_PHONE)
	public Response userIsBindPhone(HttpServletRequest request) {
		Response response;
		try {
			UserVerifyBindPhoneRequest userVerifyBindPhoneRequest = new UserVerifyBindPhoneRequest();
			userVerifyBindPhoneRequest.parse(request);
			response = userAccountInfoService.isBindPhoneByUsername(userVerifyBindPhoneRequest);
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
	
	/**
	 * 手机动态密码登录接口 
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(USER_DYNAMIC_PASSWORD_LOGIN)
	public Response userDynamicPasswordLogin(HttpServletRequest request) {
		Response response;
		try {
			UserLoginByDynamicPasswordRequest loginByDynamicPasswordRequest = new UserLoginByDynamicPasswordRequest();
			loginByDynamicPasswordRequest.parse(request);
			response = userAccountInfoService.loginByDynamicPassword(loginByDynamicPasswordRequest);
			
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
	
	/**
	 * 发送手机动态密码接口
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(USER_DYNAMIC_PASSWORD_SEND)
	public Response userDynamicPaswordSend(HttpServletRequest request) {
		Response response;
		try {
			SmsSendDynamicPasswordRequest smsSendDynamicPasswordRequest = new SmsSendDynamicPasswordRequest(); 
			smsSendDynamicPasswordRequest.parse(request);
			response = userAccountInfoService.sendDynamicPaswordByUsername(smsSendDynamicPasswordRequest);
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
	
	/**
	 * 发送开发平台用户激活邮件接口
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(USER_OPEN_PLATFORM_ACTIVITE_EMAIL_SEND)
	public Response userOpenPlatformActiviteEmailSend(HttpServletRequest request) {
		Response response;
		try {
			OpenPlatformSendActivateEmailRequest sendActivateEmailRequest = new OpenPlatformSendActivateEmailRequest(); 
			sendActivateEmailRequest.parse(request);
			response = userAccountInfoService.sendActivataAccountEmail(sendActivateEmailRequest);
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
	
	@RequestMapping(USER_ACCOUNT_LIST)
	public Response userAccount(HttpServletRequest request) {
		Response response;
		try {
			UserAccountInfoListRequest listRequest = new UserAccountInfoListRequest(); 
			listRequest.parse(request);
			response = userAccountInfoService.listUserAccount(listRequest);
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
	
	@RequestMapping(OBTAIN_USER_AUTHORIZATION)
	public Response obtainAuthorization(HttpServletRequest request){
		Response response;
		try {
			UserAccountAuthorizationUpdateRequest authorizationRequest = new UserAccountAuthorizationUpdateRequest(); 
			authorizationRequest.parse(request);
			response = userAccountInfoService.obtainAuthorization(authorizationRequest);
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
}
